package study.java.thread08;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
* @Name: GetSumCallableDemo
* @Description: 整数求和线程测试类调用类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-10 上午9:43:34 
* @Version: V1.0
 */
public class GetSumCallableDemo {
	
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		//创建线程池对象
		ExecutorService pool = Executors.newFixedThreadPool(3) ;
		//执行线程方法，获取call()方法的返回值
		Future<Integer> f1 = pool.submit(new GetSumCallable(5)) ;
		Future<Integer> f2 = pool.submit(new GetSumCallable(10)) ;
		Future<Integer> f3 = pool.submit(new GetSumCallable(15)) ;
		//输出返回结果
		System.out.println("5的和为：" + f1.get());
		System.out.println("10的和为：" + f2.get());
		System.out.println("15的和为：" + f3.get());
	}

}
